package com.xbongbong.saas.model.impl;

import com.xbongbong.saas.domain.dao.PurchaseBalanceDao;
import com.xbongbong.saas.domain.entity.PurchaseBalanceEntity;
import com.xbongbong.saas.model.PurchaseBalanceModel;;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * @author bomfish
 */
@Service("purchaseBalanceModel")
public class PurchaseBalanceModelImpl implements PurchaseBalanceModel {
    @Resource
    private PurchaseBalanceDao purchaseBalanceDao;

    @Override
    public Long insert(PurchaseBalanceEntity entity) {
        return purchaseBalanceDao.insert(entity);
    }

    @Override
    public void insertBatch(List<PurchaseBalanceEntity> list) {
        purchaseBalanceDao.insertBatch(list);
    }

    @Override
    public List<PurchaseBalanceEntity> findEntitys(Map<String, Object> param) {
        return purchaseBalanceDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return purchaseBalanceDao.getEntitysCount(param);
    }

    @Override
    public void update(PurchaseBalanceEntity entity) {
        purchaseBalanceDao.update(entity);
    }

    @Override
    public PurchaseBalanceEntity getByKey(Long key, String corpid) {
        return purchaseBalanceDao.getByKey(key, corpid);
    }

    @Override
    public void batchUpdateDel(String corpid,List<String> onlyKeyIn,Integer del) {
        purchaseBalanceDao.batchUpdateDel(corpid, onlyKeyIn, del);
    }

    @Override
    public List<PurchaseBalanceEntity> findByOnlyKeys(String corpid, List<String> onlyKeyList) {
        if (CollectionUtils.isEmpty(onlyKeyList)){
            return new ArrayList<>();
        }
        return purchaseBalanceDao.findByOnlyKeys(corpid, onlyKeyList);
    }

    @Override
    public void updateBatch(List<PurchaseBalanceEntity> purchaseBalanceEntityList,String corpid) {
        purchaseBalanceDao.updateBatch(purchaseBalanceEntityList, corpid);
    }

    @Override
    public PurchaseBalanceEntity getByOnlyKey(String corpid, String onlyKey) {
        return purchaseBalanceDao.getByOnlyKey(corpid,onlyKey);
    }


}
